home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / Regex / src / Regex.h < prev   
C/C++ Source or Header  |  1991-06-14  |  2KB  |  58 lines

  1. #ifndef RJS_REGEX_CLASS_H
  2. #define RJS_REGEX_CLASS_H
  3.  
  4. #include <RJS/String.h>
  5.  
  6. struct re_pattern_buffer;
  7. struct re_registers;
  8.  
  9. class RJS_Regex : public RJS_StringSearch, private RJS_String {
  10. protected:
  11.   re_pattern_buffer *buf;
  12.   re_registers      *reg;
  13.   char *compile_error; // the error message if any
  14.   int changed;
  15.   void  initialize(const char* t, int tlen, int fast, 
  16.                                 int bufsize, const char* transtable);
  17. public:
  18.      RJS_String &Str() { return RJS_String::Str(); }
  19.      void update() { changed=1; }
  20.      RJS_Regex(); 
  21.      RJS_Regex(const RJS_Regex &r);
  22.      RJS_Regex(const char* t, int fast = 0, int bufsize = 40,const char *tt = 0);
  23.      RJS_Regex(const RJS_String& x,int fast = 0,int bufsize = 40, const char *tt = 0);
  24.      ~RJS_Regex();
  25.      void operator=(const RJS_Regex &r); 
  26.      void operator=(const char *s);
  27.      void operator=(const RJS_String &s);
  28.      int compile();
  29.      int match(const char* s, int len = -1, int pos = 0) const;
  30.      int match(const RJS_String &s) const;
  31.      int search(const char* s,int &matchlen, int len = -1,int startpos = 0) const;
  32.      int search(const RJS_String &s, int &matchlen) const;
  33.    
  34.      int match_info(int& start, int& length, int nth = 0) const;
  35.      char *error() const { return compile_error; }
  36.      int ok() const;
  37.      operator void *() { return (void *) ok(); }
  38. };
  39.  
  40. // some built in regular expressions
  41.  
  42. extern const RJS_Regex RXwhite;          // = "[ \n\t\r\v\f]+"
  43. extern const RJS_Regex RXoptwhite;          // = "[ \n\t\r\v\f]*"
  44. extern const RJS_Regex RXnonwhite;       // = "[^ \n\t\r\v\f]+"
  45. extern const RJS_Regex RXint;            // = "-?[0-9]+"
  46. extern const RJS_Regex RXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
  47.                                      //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
  48.                                      //    \\([eE][---+]?[0-9]+\\)?"
  49. extern const RJS_Regex RXalpha;          // = "[A-Za-z]+"
  50. extern const RJS_Regex RXlower;          // = "[a-z]+"
  51. extern const RJS_Regex RXupper;          // = "[A-Z]+"
  52. extern const RJS_Regex RXalphanum;       // = "[0-9A-Za-z]+"
  53. extern const RJS_Regex RXid;             // = "[A-Za-z_][A-Za-z0-9_]*"
  54. extern const RJS_Regex RXstr;            // = "\"[^\"]\""
  55. extern const RJS_Regex RXstrq;           // = "\"\\([^\"\\]\\|\\\\\"\\|\\\\\\)*\"" 
  56.  
  57. #endif
  58.